<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<lv-collapse [lvMultiExpansion]="false" lvType="simple">
    <lv-collapse-panel [lvTitle]="titleTpl" [lvExpanded]="false">
        <lv-form [formGroup]="formGroup" [lvLabelColon]="false" class="formGroup">
            <lv-form-item>
                <lv-form-label>
                    {{'protection_clients_label' | i18n}}
                </lv-form-label>
                <lv-form-control>
                    <lv-select [lvOptions]="hostOptions" formControlName="proxyHost" lvValueKey='value' lvShowFilter
                        lvShowCheckAll lvFilterKey='label' lvFilterMode='contains' lvMode="multiple"
                        [lvContentTemplate]="contentTpl">
                    </lv-select>
                    <ng-template #contentTpl let-item>
                        <lv-group lvGutter="4px">
                            <i lv-icon="{{
                                  item.linkStatus === dataMap.resource_LinkStatus_Special.normal.value ? 'aui-host-online' : 'aui-host-offline'
                                }}"></i>
                            <span>{{ item.label }}</span>
                        </lv-group>
                    </ng-template>
                </lv-form-control>
            </lv-form-item>
            <!-- 修改索引设置 -->
            <aui-update-index [formGroup]="formGroup" [extParams]="extParams"
                [noNeedMgt]="!includes([dataMap.Resource_Type.APSCloudServer.value, dataMap.Resource_Type.vmGroup.value],resourceType)"></aui-update-index>
            <ng-container
                *ngIf="!includes([dataMap.Resource_Type.APSCloudServer.value, dataMap.Resource_Type.vmGroup.value],resourceType)">
                <lv-form-item>
                    <lv-form-label>
                        {{'protection_overwrite_policy_label' | i18n}}
                        <i lv-icon="aui-icon-help" *ngIf="!isResourceSet"
                            lv-tooltip="{{'protection_overwrite_policy_aps_help_label' | i18n}}"
                            lvTooltipPosition="rightTop"  class="configform-constraint"
                            lvColorState='true'></i>
                    </lv-form-label>
                    <lv-form-control>
                        <lv-radio-group formControlName="slaOverwrite">
                            <lv-group [lvGutter]="'8px'" lvDirection='vertical' class="mgt-8">
                                <lv-radio [lvValue]="true" [lvDisabled]="resourceData.protectedObject?.slaId">
                                    {{'protection_overwrite_hcs_project_sla_label' | i18n}}
                                </lv-radio>
                                <lv-radio [lvValue]="false" [lvDisabled]="resourceData.protectedObject?.slaId">
                                    {{'protection_not_overwrite_hcs_project_sla_label' | i18n}}
                                </lv-radio>
                            </lv-group>
                        </lv-radio-group>
                    </lv-form-control>
                </lv-form-item>
                <lv-form-item>
                    <lv-form-label>
                        {{'protection_apply_policy_label' | i18n}}
                    </lv-form-label>
                    <lv-form-control>
                        <lv-checkbox-group formControlName="slaPolicy" [lvDisabled]="disabled">
                            <lv-group [lvGutter]="'8px'" lvDirection='vertical' class="mgt-8">
                                <lv-checkbox lvValue="APPLY_TO_ALL">
                                    {{ (isResourceSet? 'protection_apply_sla_in_resource_set_project_label' :
                                    'protection_apply_sla_in_aps_project_label') | i18n }}
                                    <i lv-icon="aui-icon-help" *ngIf="!isResourceSet"
                                        lv-tooltip="{{'protection_aps_sla_help_label' | i18n}}"
                                        lvTooltipPosition="rightTop"  lvColorState='true'></i>
                                </lv-checkbox>
                                <lv-checkbox lvValue="APPLY_TO_NEW">
                                    {{(isResourceSet ? 'protection_apply_sla_in_new_resource_project_label' :
                                    'protection_apply_sla_in_new_aps_project_label') | i18n }}
                                </lv-checkbox>
                            </lv-group>
                        </lv-checkbox-group>
                    </lv-form-control>
                </lv-form-item>
                <aui-protect-filter [formGroup]="formGroup" [valid$]="valid$" [resType]="resourceType">
                </aui-protect-filter>
            </ng-container>
        </lv-form>
    </lv-collapse-panel>
</lv-collapse>

<ng-template #titleTpl>
    <lv-group lvGutter='8px'>
        <span class="aui-h3">{{'common_advanced_label'|i18n}}</span>
    </lv-group>
</ng-template>
